package com.example.adapter;

import com.example.adapter.media.MediaPlayer;
import com.example.adapter.media.impl.MediaAdapter;
import org.springframework.util.StringUtils;

/**
 * @Description TODO
 * @Date 2021/10/29 10:51
 * @Author ZhangJi
 * @Version 1.0
 */
public class AudioPlayer implements MediaPlayer {

  MediaAdapter mediaAdapter;

  @Override
  public void play(String audioType, String fileName) {
    if (!StringUtils.hasLength(audioType) || !StringUtils.hasLength(fileName)) {
      System.out.println("文件类型或文件名称为空，请检查！");
    }
    boolean advancedPlayer = "mp4".equalsIgnoreCase(audioType)
        || "vlc".equalsIgnoreCase(audioType);
    if ("mp3".equalsIgnoreCase(audioType)) {
      System.out.println("mp3"+fileName);
    }else if (advancedPlayer) {
      mediaAdapter = new MediaAdapter(audioType);
      mediaAdapter.play(audioType,fileName);
    }
  }

}
